package com.tianxiao.faas.application.web.corner;

import com.tianxiao.faas.api.param.corner.OrderHistoryDetailsResult;
import com.tianxiao.faas.api.param.corner.ShopDetailsResult;
import com.tianxiao.faas.application.aop.AuthenticationContextHolder;
import com.tianxiao.faas.biz.service.corner.ShareService;
import com.tianxiao.faas.common.access.Access;
import com.tianxiao.faas.common.result.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/app/share")
public class ShareController {


    @Resource
    private ShareService shareService;

    @RequestMapping(value = "/get")
    @Access
    public Result<?> get(String shareId) {
        Object object = shareService.get(shareId);
        if (object instanceof OrderHistoryDetailsResult) {
            OrderHistoryDetailsResult orderHistoryDetailsResult = (OrderHistoryDetailsResult) object;
            return Result.builder().success(true).data(orderHistoryDetailsResult);
        }
        if (object instanceof ShopDetailsResult) {
            ShopDetailsResult shopDetailsResult = (ShopDetailsResult) object;
            return Result.builder().success(true).data(shopDetailsResult);
        }
        return Result.builder().success(false).msg("未知错误");
    }
}
